﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PayexpDAL;

namespace Moneymatters
{
    public class PanelDetails
    {
        public PanelDetails(Guid guid, bool isNew)
        {
            this._guid = guid;
            this._isNew = isNew;
        }

        private Guid _guid;

        public Guid Guid
        {
            get { return _guid; }
        }

        private Panel _panelWithControls;

        public Panel PanelWithControls
        {
            get { return _panelWithControls; }
            set { _panelWithControls = value; }
        }

        private bool _isNew;

        public bool IsNew
        {
            get { return _isNew; }
            set { _isNew = value; }
        }

        private bool _isDirty;

        public bool IsDirty
        {
            get 
            {
                if (this._isDirty)
                {
                    return true;
                }
                else if (this.childrenChequeDetails.Count > 0 &&
                         this.childrenChequeDetails.Any(t => t.IsDirty))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            set { _isDirty = value; }
        }

        private bool isDeleted;

        public bool IsDeleted
        {
            get { return isDeleted; }
            set { isDeleted = value; }
        }

        private bool _isDiscarded;

        public bool IsDiscarded
        {
            get { return _isDiscarded; }
            set { _isDiscarded = value; }
        }

        private bool isParentDeleted;

        public bool IsParentDeleted
        {
            get { return isParentDeleted; }
            set { isParentDeleted = value; }
        }

        private List<PanelDetails> childrenChequeDetails = new List<PanelDetails>();

        public List<PanelDetails> ChildrenChequeDetails
        {
            get { return childrenChequeDetails; }
            set { childrenChequeDetails = value; }
        }

        private PanelDetails _parentTransactionMasterPanelDetails;

        public PanelDetails ParentTransactionMasterPanelDetails
        {
            get { return _parentTransactionMasterPanelDetails; }
            set { _parentTransactionMasterPanelDetails = value; }
        }

        private object _dataForPersistence;

        public object DataForPersistence
        {
            get { return _dataForPersistence; }
            set { _dataForPersistence = value; }
        }

        private List<TransactionType> _selectedTransactionTypes = new List<TransactionType>();

        public List<TransactionType> SelectedTransactionTypes
        {
            get { return _selectedTransactionTypes; }
        }

        private string _selectedFilePathForSaving;

        public string SelectedFilePathForSaving
        {
            get { return _selectedFilePathForSaving; }
            set { _selectedFilePathForSaving = value; }
        }

        private string _selectedDocTypeForSaving;

        public string SelectedDocTypeForSaving
        {
            get { return _selectedDocTypeForSaving; }
            set { _selectedDocTypeForSaving = value; }
        }

        private string _providedNarration;

        public string ProvidedNarration
        {
            get { return _providedNarration; }
            set { _providedNarration = value; }
        }

        private bool _isReconciled;

        public bool IsReconciled
        {
            get { return _isReconciled; }
            set { _isReconciled = value; }
        }

        private bool _isAutoApproved;

        public bool IsAutoApproved
        {
            get { return _isAutoApproved; }
            set { _isAutoApproved = value; }
        }

        private int? _bankAccountsId;

        public int? BankAccountsId
        {
            get { return _bankAccountsId; }
            set { _bankAccountsId = value; }
        }
    }

    public class ComboBoxItem
    {
        private string _displayValue;

        public string DisplayValue
        {
            get { return _displayValue; }
        }

        private object _value;

        public object Value
        {
            get { return _value; }
        }

        public ComboBoxItem(string displayValue, object value)
        {
            this._displayValue = displayValue;
            this._value = value;
        }

        public override string ToString()
        {
            return this.DisplayValue;
        }

    }

    public class CheckedListBoxItem
    {
        private string _displayValue;

        public string DisplayValue
        {
            get { return _displayValue; }
        }

        private object _value;

        public object Value
        {
            get { return _value; }
        }

        public CheckedListBoxItem(string displayValue, object value)
        {
            this._displayValue = displayValue;
            this._value = value;
        }

        public override string ToString()
        {
            return this.DisplayValue;
        }

    }

    public class ValidationException : Exception
    {
        public ValidationException(string message) : base(message)
        {

        }
    }
}
